home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX 6.2 Applications 1996 May
/
SGI IRIX 6.2 Applications 1996 May.iso
/
dist
/
impr_dev.idb
/
usr
/
include
/
spool.h.z
/
spool.h
Wrap
C/C++ Source or Header
|
1996-05-06
|
14KB
|
357 lines
/**************************************************************************
* *
* Copyright (c) 1991 Silicon Graphics, Inc. *
* All Rights Reserved *
* *
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI *
* *
* The copyright notice above does not evidence any actual of intended *
* publication of such source code, and is an unpublished work by Silicon *
* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is *
* the property of Silicon Graphics, Inc. Any use, duplication or *
* disclosure not specifically authorized by Silicon Graphics is strictly *
* prohibited. *
* *
* RESTRICTED RIGHTS LEGEND: *
* *
* Use, duplication or disclosure by the Government is subject to *
* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in *
* Technical Data and Computer Software clause at DFARS 52.227-7013, *
* and/or in similar or successor clauses in the FAR, DOD or NASA FAR *
* Supplement. Unpublished - rights reserved under the Copyright Laws of *
* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. *
* Shoreline Blvd., Mountain View, CA 94039-7311 *
**************************************************************************
*
* File: spool.h
*
* Description: Primary include file for libspool, the printer spooling
* system API library. This file contains the declarations and
* information required by application programs and should be
* included by any program that references functions in libspool.
*
**************************************************************************/
#ident "$Revision: 1.5 $"
#ifndef _SL_SPOOL_H
#define _SL_SPOOL_H
#include <sys/types.h>
/* Spooling systems */
#define SL_SPOOLER_NONE 0
#define SL_SPOOLER_BSD 1
#define SL_SPOOLER_SYSV 2
#define SL_POSSIBLE_SPOOLERS ( SL_SPOOLER_BSD | SL_SPOOLER_SYSV )
#define SL_SPOOLER_PREF SL_SPOOLER_SYSV
/* Spooler function and state info */
#define SL_PRINTING 0
#define SL_QUEUEING 1
#define SL_DISABLED 0
#define SL_ENABLED 1
/* Print queue types */
#define SL_QUEUE_LOCAL 1
#define SL_QUEUE_REMOTE 2
#define SL_QUEUE_MERGED 3
/* Printer specific options file save location tokens */
#define SL_SAVE_USER 0
#define SL_SAVE_DEFAULT 1
/* Default netork timeout, in seconds */
#define SL_NET_TIMEOUT 20
/* Error codes - indices into the SLerrlist array (except for SL_ERROR) */
#define SL_ERROR -1
#define SL_NOERROR 0 /* No error detected */
#define SL_ERR_FIND_SPOOLER 1 /* Could not shell out */
#define SL_ERR_SPOOLER_NONE 2 /* SL_SPOOLER_NONE default */
#define SL_ERR_NO_SPOOLERS 3 /* No spooling systems */
#define SL_ERR_SPOOLER_UNKNOWN 4 /* Unknown spooling system */
#define SL_ERR_NO_FILENAME 5 /* Invalid or missing filename*/
#define SL_ERR_NUM_COPIES 6 /* Invalid num copies */
#define SL_ERR_JOB_COPY 7 /* Invalid copy/link param */
#define SL_ERR_NO_DEF_PRINTER 8 /* No default printer */
#define SL_ERR_SPOOLER_ERROR 9 /* Spooling system error */
#define SL_ERR_NO_JOBID 10 /* No job ID specified */
#define SL_ERR_BAD_FUNCTION 11 /* Invalid spooling function */
#define SL_ERR_BAD_STATE 12 /* Invalid spooling state */
#define SL_ERR_NO_STATE 13 /* Can't get spooler state */
#define SL_ERR_BAD_PRINTER_STRUCT 14 /* Invalid printer struct */
#define SL_ERR_REMOTE 15 /* Can't get to remote host */
#define SL_ERR_PRIVILEGE 16 /* Need root privilege */
#define SL_ERR_MAIL 17 /* Invalid mail param */
#define SL_ERR_BAD_FD 18 /* Invalid file descriptor */
#define SL_ERR_BAD_BUF 19 /* Invalid print buffer */
#define SL_ERR_BAD_PRINTER_NAME 20 /* Invalid printer name */
#define SL_ERR_BAD_CLASS_MEMBER 21 /* Invalid class member */
#define SL_ERR_NO_TEMP_FILE 22 /* Unable to create temp file*/
#define SL_ERR_BAD_SOCKET 23 /* Problem with a socket */
#define SL_ERR_NO_FAST_JOB 24 /* Fast job not supported */
#define SL_ERR_NO_SYSV 25 /* System V spooler required */
#define SL_ERR_SAVE_OPTIONS 26 /* Can't save options file */
/* Printer structure */
/* This structure describes a printer. The following notes
apply:
1. On BSD systems it is assumed that the formal_name
is the last printer name to appear in the name list.
2. On any spooling system, if the formal_name cannot
be determined it will be set to the type;
3. On BSD systems the type field may be unavailble from
the /etc/printcap file and will be set to "Unknown".
4. For networked printers the dev field will be set to
a NULL pointer.
5. If the printer is local, the remote_host and remote_name
fields will be set to the NULL pointer.
6. On BSD systems since one physical printer can have a
number of names, it is possible to have more than one
printer in the list marked as the default printer.
7. On System V systems the is_class field is 1 if the printer
is actually a class. On BSD systems this field is always
false.
*/
typedef struct _slPrinterStruct {
char *local_name; /* Printer name on the local machine */
char *formal_name; /* Complete formal printer name */
char *type; /* Type of printer (eg. Color) */
char *dev; /* Port name (eg. /dev/plp) */
/* NULL pointer if networked */
unsigned int is_def: 1; /* 1 == printer is the default */
unsigned int is_class: 1; /* 1 == print is class (Sys V only) */
unsigned int is_networked: 1; /* 1 == printer is physically */
/* located on a remote machine */
unsigned int _padding: 29; /* Unused - for word alignment */
char *remote_host; /* Name of remote machine */
char *remote_name; /* Name of printer on remote machine */
char *network_type; /* Type of network connection */
/* to remote machine */
} SLPrinterStruct;
/* Printer settings structure */
/* The SGI printing environment provides a mechanism for
saving printer option settings on a per user per
printer basis. The PrintPanel tool allows a user to
set various job and printer related options and save
these settings. libspool provides the SLGetPrinterSettings
function to read the saved job and printer settings in
a spooler independent manner. This structure provides the
settings information. The settings information as contained
in this structure can be passed as parameters to the libspool
print job submittal functions such as SLSubmitJob. To read
spooling system specific settings refer to SLSysVGetPrinterSettings
and the SLSysVSettingsStruct below. The following notes apply:
1. Printer and job settings are currently supported
only under System V spooling. Under BSD spooling
all fields will be set to default values.
*/
typedef struct _slSettingsStruct {
int copy; /* 1 == copy to spooling area, 0 == link */
int mail; /* 1 == send mail on job completion, 0 == no mail */
char *title; /* Print job banner page title. If NULL the system */
/* default banner title is to be used. */
char *options; /* Spooling system specific options (e.g. -w and */
/* -o under System V) */
} SLSettingsStruct;
/* System V spooler specific settings structure */
/* The SLGetSysVPrinterSettings function is similar to
SLGetPrinterSettings but provides the only spooler settings
and provides them in a System V spooling system dependent
manner. See SLGetPrinterSettings above to obtain all settings
in a spooling system independent manner.
*/
typedef struct _slSysVSpoolerOptionsStruct {
int copy; /* 1 == copy to spooling area, 0 == link */
int mail; /* 1 == send mail on job completion, 0 == no mail */
int message; /* 1 == send message on job completion, 0 == no msg */
int suppress_id; /* 1 == suppress job ID message, 0 == show ID */
char *title; /* Print job banner page title. If NULL the system */
/* default banner title is to be used. */
} SLSysVSpoolerOptionsStruct;
/* Print job structure */
/* This structure describes a print job. A pointer to this
structure is returned after a job has been successfully
submitted for printing. The following notes apply:
1. The job submittal functions maintain an internal
static structure for print jobs. The structure is
reused for each job submitted. It is the users
responsibility to make a copy of the job structure
if it is to be preserved.
2. On BSD systems the job_id field will be NULL. To determine
the job ID one must examine the BSD queue and manually
determine the relevant job ID.
3. On System V systems the job_id field will be NULL if
the '-s' flag is specified as an option.
4. The username field contains the name of the user who
submitted the job. The name is derived based on the
real uid, not the euid. This is because the spooling
system lists the owner of a job based on the real uid.
If the username cannot be determined, "Unknown" is entered
in this field.
*/
typedef struct _slPrintJob {
unsigned int spooler; /* Spooling system that owns the job */
/* eg. SL_SPOOLER_BSD */
char *printer; /* Local name of the printer */
char *filename; /* Name of file(s) to be printed */
char *username; /* Job owner user name */
char *job_id; /* Job ID, where available */
time_t time_stamp; /* Time string from time(2). */
/* See also ctime(3) */
} SLPrintJob;
/* Fast print job structure */
/* This stucture describes a fast print job; a pointer to this
structure is returned from a call to SLBeginFastJob, and it
contains information necessary for an application to execute
the fast print job. The following notes apply:
1. Only supported in System V spooler
*/
typedef struct _slFastPrintJob {
int sock; /* A socket which has been marked as */
/* listening, which should be passed to */
/* accept, after which data can be sent */
/* to the printer driver */
SLPrintJob *job; /* The return value of SLSubmitJobFile, which */
/* marks the job as it snakes its way through */
/* the spooling system */
} SLFastPrintJob;
/* Print queue entry */
/* This structure describes an entry on a printer queue.
The following notes apply:
1. On BSD systems the time_stamp is 0.
2. On BSD systems the is_local field is always 1.
*/
typedef struct _slQueueStruct {
char *job_id; /* Job ID */
char *username; /* Job owner's user name */
char *title; /* Print job title, or name of */
/* first file in request */
unsigned int size; /* Size of the job in bytes */
unsigned int is_local: 1; /* 1 == job is in the local */
/* queue (Sys V only) */
unsigned int _padding: 31; /* Unused - for word alignment */
time_t time_stamp; /* Submittal time (Sys V only) */
/* From time(2). See also ctime(3) */
} SLQueueStruct;
/* Public global variables */
extern int SLdebug; /* Debug flag. Set non-zero for runtime info */
extern long SLnet_timeout; /* Timeout (seconds) for network operations */
extern int SLerrno; /* Error variable */
extern char *SLerrlist[]; /* Error strings */
extern int SLnerr; /* Number of error strings in SLerrlist */
/* Public function declarations */
#ifdef __cplusplus
extern "C" {
#endif
extern void SLPerror(const char *str);
extern char* SLErrorString(int err_code);
extern int SLGetSpooler(unsigned int *defaultp, unsigned int *availablep);
extern int SLSetSpooler(unsigned int spooler);
extern int SLGetPrinterList(SLPrinterStruct *printersp[],
int *num_printersp);
extern int SLGetPrinterInfo(const char *printer,
SLPrinterStruct **printer_infop);
extern int SLGetDefPrinterName(char **pnamep);
extern int SLGetPrinterSettings(const char *printer,
SLSettingsStruct **settingsp);
extern int SLSysVGetSpoolerOptions(SLSysVSpoolerOptionsStruct
**spooler_optsp);
extern int SLSysVGetPrinterOptions(const char *printer,
char **printer_optsp);
extern int SLSysVSaveSpoolerOptions(SLSysVSpoolerOptionsStruct
*spooler_opts);
extern int SLSysVSavePrinterOptions(const char *printer,
char *printer_opts, int location);
extern SLPrintJob* SLSubmitJob(const char *filename, const char *printer,
int num_copies, int copy, int mail,
const char *title, const char *options);
extern SLPrintJob* SLSubmitJobFd(int file_desc, const char *printer,
int num_copies, int copy, int mail,
const char *title, const char *options);
extern SLPrintJob* SLSubmitJobBuf(const void *buffer, size_t amount,
const char *printer, int num_copies,
int copy, int mail, const char *title,
const char *options);
extern SLPrintJob* SLSubmitJobSimple(const char *filename);
extern int SLCancelJob(const char *job_id, unsigned int spooler,
const char *printer);
extern int SLGetSpoolerState(const char *printer, int function,
int *statep);
extern int SLSetSpoolerState(const char *printer, int function,
int state);
extern int SLGetQueue(const SLPrinterStruct *printer_info, int queue_type,
SLQueueStruct *queuep[], int *num_queuep);
extern int SLGetSpoolerError(char **out_bufp[], int *noutp);
#ifdef _SL_FASTPATH
/* DO NOT REFERENCE THESE FUNCTIONS */
/* Code bracketed by _SL_FASTPATH is unsupported in this release. */
extern SLFastPrintJob* SLBeginFastJob(const char *printer, int ncopies,
int mail, const char *title,
const char *options);
extern int SLEndFastJob(SLFastPrintJob *fj);
extern int SLCancelFastJob(SLFastPrintJob *fj);
extern int SLSupportsFastJob(const char *printer);
#endif /* _SL_FASTPATH */
#ifdef __cplusplus
}
#endif
#endif /* _SL_SPOOL_H */